{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}

{% block head %}
{{super()}}
{{moment.include_moment()}}
{% endblock %}
{% block title %}Flasky{% endblock %}

{% block page_content %}

    <img class="img-rounded profile-thumbnail" src="{{ user.gravatar(size=256) }}">
    <div class="user-profile">
        <h1> {{user.username}} </h1>

        {% if user == current_user %}
            <a class = "btn btn-default" href = "{{ url_for('.edit_profile') }}" >
                编辑资料
            </a>
        {% endif %}

        {% if user.name or user.location %}
            <p>
                {% if user.name %}{{ user.name }}{% endif %}
                {% if user.location %}
                    From <a href = "http://maps.google.com/?q={{ user.location }}" >
                    {{user.location}}
                </a>
                {% endif %}
            </p>
        {% endif %}
        {% if current_user.is_administrator() %}
            <p > <a href = "mailto:{{ user.email }}" > {{user.email}} </a> </p>
        {% endif %}
        {% if user.about_me %} <p> 关于我:{{ user.about_me }} </p> {% endif %}

            注册时间 {{moment(user.member_since).format('YYYY/MM/DD HH:MM')}}.

            上次访问日期 {{moment(user.last_seen).fromNow()}}.

            <p>
                {% if current_user.can(Permission.FOLLOW) and user != current_user %}
                    {% if not current_user.is_following(user) %}
                        <a href="{{ url_for('.follow', username=user.username) }}"
                        class="btn btn-primary">关注</a>
                    {% else %}
                             <a href="{{ url_for('.unfollow', username=user.username) }}"
                                 class="btn btn-default">取消关注</a>
                    {% endif %} {% endif %}
                         <a href="{{ url_for('.followers', username=user.username) }}">
                             关注我的人: <span class="badge">{{ user.followers.count() }}</span>
                         </a>
                 <a href="{{ url_for('.followed_by', username=user.username) }}">
            我正在关注的: <span class="badge">{{ user.followed.count() }}</span>
            </a>
            {% if current_user.is_authenticated and user != current_user and user.is_following(current_user) %}
         | <span class="label label-default">Follows you</span>
              {% endif %}
          </p>
      </div>


        </br></br>
        <h3>近期文章by: {{ user.username }}</h3>
            {% include '_posts.html' %}
        {% if pagination %}
            <div class="pagination">
                {{ macros.pagination_widget(pagination, '.user', username=user.username) }}
            </div>
        {% endif %}

{% endblock %}




